<?php $this->load->view('admin/_header1') ?>

<div style="width:600px" class="Main">
	
	<div class="flightbox1" style="background:#fff;height:50px">
		<?=lang("OrderNo")?>:<?php echo $sOrderno?>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		Order Status:<?=$OrderStatusDesc?><BR>
		PNR:<?=$PNR?>&nbsp;&nbsp;&nbsp;
		Total Cost:<?=$mainCurrency.":".$TotalCost?>&nbsp;&nbsp;&nbsp;&nbsp;
		refund Fee:<?=$mainCurrency.":".$refundFee?>
	</div>
	<div class="flightbox1">&nbsp;&nbsp;
		<?=lang("home_From")?>:<?php echo $sFromcity?><span style="width:35px;"></span>
		<?=lang("home_To")?>:<?php echo $sDestcity?><span style="width:35px"></span>
		<?=lang("home_Depart")?>:<?php echo $sDepartDate?>
		<?=lang('home_Return')?>:<?php echo $sReturnDate;?>
	</div>
	<?php
	echo form_open("admin/Order/saveTicketNo",array("id" => "formPassenger"));
	
	echo form_hidden("Orderno",$sOrderno);
	?>
	<div id="dvmainflight" style="padding:4px 0 0 4px;">
	<table border=0 width=590 >
		<tr height=34 class="trair" align=center>
			<td width=80 ><?=lang("home_Depart")?></td>
			<td width=120 ><?=lang("FlightNo/Airline")?></td>
			<td width=138 ><?=lang("Depart/Arrival")?></td>
			<td width=45 ><?=lang("Class")?></td>
			<td width=84 ><?=lang("Plane/Stop")?></td>
			
			<td width=80 ><?=lang("Fare")?></td>
			<td width=78 ><?=lang("Tax&Fee")?></td>
			<?
			if ($arairinfo[0]["rebate"]>0)
			{
				?><td width=78 ><?=lang("rebate&vip Price")?></td>
				<?
			}
			?>
			<td width=120 ><?=lang("TotalPrice")?></td>
		</tr><?php
		$maxseat=1;
		foreach($arairinfo as $item)
		{
		?><tr height=55 class="trdash" align=center>
			<td><?=Date("Y-m-d",strtotime($item["flightdate"]));?></td>
			<td align=left style="padding-left:5px" ><?php echo "<img style=\"float:left\" width=25 height=25 src=\"".site_url("images/airlines/".$item["Airline"].".gif")."\" alt='".$item["Airline"]."' />".$item["FlightNo"] ?></td>
			<td><?php echo $item["Depart"]."&nbsp;".$item["fromport"].'<br/>'.$item["Arrival"]."&nbsp;".$item["destport"]; ?></td>
			<td><?php echo $item["class"][0][0]; ?></td>
			<td><?php echo $item["Plane"].'/'.$item["Stop"]; ?></td>
			
			<td><?php
			$itotalprice=0;
			$itotalprice=$item["cost"];
			$maxseat	=$item["class"][0][1];	
			echo $item["class"][0][2];
			
			//计算总价
			$itotalprice+=$item["OilFee"]+$item["AirportFee"];
			?></td>
			<td><?php echo $item["OilFee"]."+".$item["AirportFee"]; ?></td>
			<?
			if ($item["rebate"]>0)
			{
			?><td><?php 
				echo $item["rebate"]."%/".$item["cost"];
				?></td>
			<?php
			}
			?>
			<td><?php echo $mainCurrency.":".$itotalprice;?></td>
		 </tr>
		 <?
		}
		 ?>		
	</table>
		
	</div><!--航班信息显示结束-->
	<?php
		if($orderstatus=="3")
		{
			echo '<div class="flightbox1" style="text-align:center;height:35px;padding-top:5px;line-height:25px" >';
			echo form_label("refund Fee");
			echo form_input("refundFee",$refundFee,"class=txa verify=\"MN\" id=\"tx_refundFee\" desc=\"refund Fee\"");
			echo '<BR/></div>';
		}
		
	?>
	<div class="flightbox1" style="text-align:center;height:40px">
		<?php
		if($orderstatus=="0")
		{
			echo '<input type="button" name="bbb" onclick="confirmoper(\'9\',this);" value="Cancel Order" />&nbsp;';
			echo '<input type="button" name="bbb" onclick="confirmoper(\'1\',this);" value="confirm paid" />';
		}
		
		if($orderstatus=="1")
		{
			echo '<input type="button" name="bbb" id="btnticket" onclick="ConfirmTicketed(\'1\',this);" value="Confirm Ticketed" />&nbsp;';
			echo '<input type="button" name="bbb" onclick="confirmoper(\'7\',this);" value="Ticketed failed" />';
			if($isHuitrip)
			{
				echo '<input type="button" name="bbb" onclick="huitripoper();" value="huitrip pay" />';	
			}
			
		}
		
		if($orderstatus=="2")
		{
			echo '<input type="button" name="bbb" onclick="confirmoper(\'3\',this);" value="apply refund" />&nbsp;';
			echo '<input type="button" name="bbb" onclick="confirmoper(\'5\',this);" value="apply change" />';
		}
		
		if($orderstatus=="3")
		{
			echo '<input type="button" name="bbb" onclick="confirmoper(\'4\',this);" value="Confirm refunded" />&nbsp;';
			
			
		}
		
		if($orderstatus=="5")
		{
			echo '<input type="button" name="bbb" onclick="confirmoper(\'6\',this);" value="Confirm changed" />&nbsp;';
			echo '<input type="button" name="bbb" onclick="confirmoper(\'8\',this);" value="Cannot change" />';
		}
		
		?>
	</div>
	
	<div id="dvPrice" class="flightbox1 bookprice" style="margin-top:20px">
		Grand for total <?php echo $TotalPassenger; ?> person(all taxes and fees includes):<?php echo $mainCurrency.":".$TotalPrice; ?>
	</div>
	<!--价格信息显示结束-->
	
	<div id="dvbook" style="padding-top:19px">
		<span class="tiptitle"><?=lang("PassengerInfomation")?></span>
		<?
		
		//国际机票
		if($cpsdata[0]->note2!="")
		{
		?>
		<table border=0 width=100% class="ordertable" bordercolor=#DFDFDF  id="tbPassenger_1">
			<?php
			foreach($cpsdata as $passenger)
			{
				$PI_info=json_decode($passenger->note2);
				
				?><tr height=30 align="center" >
					<td>
						<div style="background:#E9EBF1;padding:10px" >
						<table border=0  width=100% >
							<tr align=left height=28 >
								<td width=127 ><?=lang("book_Name")?>:&nbsp;&nbsp;</td>
								<td width=214 ><?=$PI_info->PassengerName;?></td>
								<td><?=lang("book_Gender")?>:&nbsp;&nbsp;</td>
								<td><?=$arGender[$PI_info->PI_userGender];?></td>
							</tr>
							
							<tr align=left height=28 >
								<td><?=lang("book_Nationality")?>:&nbsp;&nbsp;</td>
								<td><?php
									$national=explode("||",$PI_info->PI_userNationality);
									echo $national[0];
								?></td>
								<td><?=lang("book_Dateofbirth")?>:&nbsp;&nbsp;</td>
								<td><?=$PI_info->PI_userBirth;?></td>
							</tr>
							<tr align=left height=28 ><td><?=lang("book_IDType")?>:&nbsp;&nbsp;</td>
					                <td><?=$aridType[$PI_info->CTType];?></td>
					                <td><?=lang("book_IDNumber")?>:&nbsp;&nbsp;</td>
					                <td><?=$PI_info->CTID;?></td>
					          </tr>
					          
					          <tr align=left height=28 >
					                <td><?=lang("book_IDexpirationdate")?>:&nbsp;&nbsp;</td>
					                <td align=left><?=$PI_info->PI_idExpiration;?></td>
					                <td width=127 ><?=lang("book_Mobilephone")?>:&nbsp;&nbsp;</td>
								 <td width=214><?=$PI_info->PassengerTel;?></td>
					          </tr>
					           <tr align=left height=28 >
					                <td><?=lang("book_TicketNo")?>:&nbsp;&nbsp;</td>
					                <td colspan=3 align=left><?
					                //订单支付后显示
									if($orderstatus=="1")
									{
										echo form_input("HKID[]",$passenger->HKID,"verify=\"M\" desc=\"TicketNo\"");
										echo form_hidden("passengerID[]",$passenger->PassengerID);
									}else
									{
										echo $passenger->HKID;
									}	
					                	
					                ?></td>
					          </tr>
							</table>
							</div>
							<div style="background:#fff;height:5px" ></div>
						
					</td>
				</tr><?php
			}
			?>
		</table>
		<?php
		}else
		{
		?>
		<table border=0 width=724 class="ordertable" bordercolor=#DFDFDF  id="tbPassenger_1">
			<tr height=30 class="booktitle"  >
				<th width=50><?=lang("book_Type")?></th>
				<th><?=lang("book_Name")?></th>
				<th><?=lang("book_IDType")?></th>
				<th><?=lang("book_IDNumber")?></th>
				<th><?=lang("book_Mobilephone")?></th>
				<th><?=lang("book_TicketNo")?></th>
			</tr>
			<?php
			foreach($cpsdata as $passenger)
			{
				//Type,Name,CertificateType,CTID,PPID
			
			?><tr height=30 align="center" >
				<td><?php echo $arPassType[$passenger->Type]; ?></td>
				<td><?php echo $passenger->Name; ?></td>
				<td><?php echo $aridType[$passenger->CertificateType]; ?></td>
				<td><?php echo $passenger->CTID; ?></td>
				<td><?php echo $passenger->PPID; ?></td>
				<td><?php 
					//订单支付后显示
					if($orderstatus=="1")
					{
						echo form_input("HKID[]",$passenger->HKID,"verify=\"M\" desc=\"TicketNo\"");
						echo form_hidden("passengerID[]",$passenger->PassengerID);
					}else
					{
						echo $passenger->HKID;
					}
				?></td>
			</tr><?php
			}
			?>
		</table>
		<?php
		}
		?>
		
		<?php
		if($orderstatus=="1")
		{
			echo '<div class="flightbox1" style="text-align:center;height:65px;padding-top:5px;line-height:25px" >';
			echo form_label("total cost");
			echo form_input("TotalCost",$TotalCost,"class=txa desc=\"MN\" desc=\"Total Cost\"");
			echo "<BR>";
			echo form_button("name","save Ticket No","onclick=\"CheckTicketNo()\"");
			echo '</div>';
		}
	
		
		?>
	</div>
	
	<div class="flightbox1" style="height:160px">
		<span class="tiptitle">Record operation log</span><BR>
		<textarea name="operNote" id="txoperNote" style="width:450px;height:120px" ></textarea>
		<input type="button" name="bbb" onclick="writelog();" value="Record log" />
	</div>	
	<?php 
	echo form_close();
	?>
	
	<!--预订信息显示结束-->
	<div id="dvbook" style="padding-top:19px">
		<span class="tiptitle"><?=lang("ContactInfomation")?></span>
		<table border=0 width=724 class="contactable" bordercolor=#DFDFDF >
			<tr height=32 align=left >
				<td width=230 align=right ><?=lang("book_Name")?>:&nbsp;</td>
				<td width=215 ><?php echo $LinkMan?></td>
				<td width=275 ><div id="txLinkManTip"></div></td>
			</tr>
			
			<tr height=32>
				<td align=right ><?=lang("book_Mobilephone")?>(<?=lang("within_Mainland_China")?>):&nbsp;</td>
				<td><?php echo $Mobile1?></td>
				<td><div id="txMobilephone1Tip"></div></td>
			</tr>
			
			<tr height=32>
				<td align=right><?=lang("book_Mobilephone")?>(<?=lang("outside_Mainland_China")?>):&nbsp;</td>
				<td><?php echo $Mobile2?></td>
				<td><div id="txMobilephone2Tip"></div></td>
			</tr>
			
			<tr height=32 >
				<td align=right>Email:&nbsp;</td>
				<td><?php echo $Email?></td>
				<td><div id="txEmailTip"></div></td>
			</tr>

		</table>
	</div>
	<?php
	echo form_open("admin/Order/dooperorder",array("id" => "formOrder"));
	
	echo form_hidden("Orderno",$sOrderno);
	
	?><input type=hidden name="status" id="hdn_status" value="0" />
	<input type=hidden name="refundFee" id="hdn_refundFee" value="0" /><?php
	echo form_close();
	?>
	<!--联系信息显示结束-->
	<div id="dvbook" style="padding:19px">
		<span class="tiptitle">log Infomation</span>
		<table width=590 >
			<tr align="center">
				<th width=80 >Date</th>
				<th width=300 >Context</th>
				<th width=150>User</th>
			</tr>
			<?php
			foreach($loglist as $item)
			{
			?>
			<tr align="center" >
				<td><?=$item->OperDate ?></td>
				<td align="left" style="padding-left:10px"><?=$item->OperNote."<BR>".$item->Note ?></td>
				<td><?=$item->OperAccount."<BR>".$item->AgentName ?></td>
			</tr>
			<?php
			}
			?>
		</table>
	</div>
	<!--日志信息显示结束-->
	<script language="javascript">
		
	//确认操作
	function confirmoper(stStatus,obj){
		$("#hdn_status").val(stStatus);
		
		//确认退款的时候填写退票服务费
		if(stStatus=="4")
		{
			if(!CheckFormSubmit(gd$("formPassenger")))
			{
				return false;	
			}
			gd$("hdn_refundFee").value=gd$("tx_refundFee").value;
		}
		if(confirm("Confirm to perform operation '"+obj.value+"'?"))	
		{			
			gd$("formOrder").submit();
		}
	}
	
	//确认汇游支付
	function huitripoper()
	{
		if(confirm("Confirm to pay Huitrip ?"))	
		{			
			gd$("formOrder").action="../dohuitrippay";
			gd$("formOrder").submit();
		}
	}
	
	//检查是否填写票号
	function CheckTicketNo()
	{
		if(CheckFormSubmit(gd$("formPassenger")))
		{
			gd$("formPassenger").action=_baseroot+"admin/Order/saveTicketNo";
			gd$("formPassenger").submit();
		}
	}
	//检查是否有没有保存的票号
	function ConfirmTicketed(){
		$.ajax({
			url:_baseroot+"admin/Order/checkTicketNo",
			data:"Orderno=<?=$sOrderno?>",cache:false,dataType:"json",
			success:function(jvalue){
				
				if(jvalue.Result=="0")
				{
					confirmoper(2,gd$("btnticket"));
				}else
				{
					alert("Have not to save the exchange, please keep exchange first");	
				}
			}
		});
	}
	
	//记录日志
	function writelog()
	{
		if(gd$("txoperNote").value=="")
		{
			alert("Please enter the log content");	
			return;
		}
		gd$("formPassenger").action=_baseroot+"admin/Order/writelog";
		gd$("formPassenger").submit();
	}
	</script>
</div>

<?php $this->load->view('admin/_footer1') ?>